import { Component } from '@angular/core';
import { NavController, NavParams, LoadingController } from 'ionic-angular';

import { CouponPage } from '../coupon/coupon';
import { BusinessDetail } from '../../model/business-detail';
import { BusinessService } from '../../service/business.service';

@Component({
	selector: 'page-detail',
	templateUrl: 'detail.html',
	providers:[BusinessService]
})
export class DetailPage {
	slideOptions: any;
	id: string;
	business: BusinessDetail;
	
	constructor(
		private navCtrl: NavController,
		private navParams: NavParams,
		private businessService: BusinessService,
		private loadingCtrl: LoadingController
	) {
		this.slideOptions = {
			autoplay: 3500,
			pager: true,
			initialSlide: 1,
			loop: true
		};
		this.id = navParams.get('id');
	};

	ionViewWillEnter(){
		let loader = this.loadingCtrl.create({
	      spinner:'crescent'
	    });  
		loader.present();
		this.businessService.listDetail(this.id).then( res => {
			this.business = res;
			loader.dismiss();
		});
	};
	
	getCoupon() {
		this.navCtrl.push(CouponPage)
	}
}
